/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class RoomTypeModel  extends AbstractTableModel {
     
    ArrayList<entity.RoomType> list ;
    public RoomTypeModel(ArrayList<entity.RoomType> list ){
        this.list = list;
    }
    public final static String[] columnNames = {
       "Tên Loại phòng","Giá phòng"
    };
    public int getRowCount() {
       return list.size();
    }

    public int getColumnCount() {
        return columnNames.length;
    }

    public Object getValueAt(int row, int col) {
          switch(col){
              case 0:return list.get(row).getName();            
              case 1:return list.get(row).getCost();       
              default: return null;  
            }
    }
    public String getColumnName(int columnIndex) {
        return columnNames[columnIndex];
    }
      public void refesh(){
        fireTableDataChanged();
    }
    public void removeRow(int row) {
        list.remove(row);
        fireTableDataChanged();
    }
    public void insertList(entity.RoomType e){
        list.add(e);
        fireTableDataChanged();       
    }
    public void editList(int index,entity.RoomType e){
         list.remove(index);
         list.add(index, e);
         fireTableDataChanged();    
    }
}
